/*
 * @version: 
 * @Author: yu
 * @Date: 2023-07-17 18:00:21
 * @LastEditors: Andy
 * @LastEditTime: 2023-07-17 18:43:32
 */
import React, { useState } from 'react';
import { Button, Menu } from 'antd';
import {
    WindowsOutlined,
    RestOutlined,
    ShoppingOutlined,
} from '@ant-design/icons';
import { useNavigate, useLocation } from 'react-router-dom'

function getItem(label, key, icon, children, type) {
    return {
        key,
        icon,
        children,
        label,
        type,
    };
}
const items = [
    getItem('首页', '/home', <WindowsOutlined />),
    getItem('系统管理', '1', <RestOutlined />, [
        getItem('菜单管理', '/menu'),
        getItem('角色管理', '/role'),
        getItem('管理员管理', '/user'),
    ]),
    getItem('商城管理', '2', <ShoppingOutlined />, [
        getItem('商城分类', '/cart'),
        getItem('商城商品', '/goods'),
    ]),
];


export default function Nav() {
    let Navigate = useNavigate()
    //封装一个跳转事件
    const getDetail = (e) => {
        // console.log(e);
        Navigate('/index' + e.key)
    }
    return (
        <div>
            <Menu
                mode="inline"
                items={items}
                onClick={getDetail}
            />
        </div>
    )
}
